package com.project.frba.bifront.server.rpc;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.project.frba.bi.BiUtil;
import com.project.frba.bi.ETLExecutor;
import com.project.frba.bi.TimeQuantityParser;
import com.project.frba.bifront.client.rpc.ETLServices;

public class ETLServicesImpl extends RemoteServiceServlet implements ETLServices {
	
	@Override
	public Boolean executeETLService(String descriptorName) {
		ETLExecutor executor = BiUtil.getETLExecutor();
		executor.execute(descriptorName);
		return true;
	}

	@Override
	public Boolean changeExecutionTime(String descriptorName, String delayPattern) {
		TimeQuantityParser timeParser = new TimeQuantityParser();
		Long delay = timeParser.convertUponSet(delayPattern);
		if (delay != 0) { 
			ETLExecutor executor = BiUtil.getETLExecutor();
			executor.changeExecutionTime(descriptorName, delay);
		} else {
			return false;
		}
		
		return true;
	}


	@Override
	public Boolean executeAllETLServices() {
		ETLExecutor executor = BiUtil.getETLExecutor();
		executor.executeAll();
		return true;
	}

}
